EC-CUBE 2.11.4
[ class tree: EC-CUBE 2.11.4 ] [ index: EC-CUBE 2.11.4 ] [ all elements ]

Source for file SC_Session.php

Documentation is available at SC_Session.php

  1. <?php
  2. /*
  3.  * This file is part of EC-CUBE
  4.  *
  5.  * Copyright(c) 2000-2011 LOCKON CO.,LTD. All Rights Reserved.
  6.  *
  7.  * http://www.lockon.co.jp/
  8.  *
  9.  * This program is free software; you can redistribute it and/or
  10.  * modify it under the terms of the GNU General Public License
  11.  * as published by the Free Software Foundation; either version 2
  12.  * of the License, or (at your option) any later version.
  13.  *
  14.  * This program is distributed in the hope that it will be useful,
  15.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  17.  * GNU General Public License for more details.
  18.  *
  19.  * You should have received a copy of the GNU General Public License
  20.  * along with this program; if not, write to the Free Software
  21.  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  22.  */
  23.  
  24. /* セッション管理クラス */
  25. class SC_Session {
  26.  
  27.     /** ログインユーザ名 */
  28.     var $login_id;
  29.  
  30.     /** ユーザ権限 */
  31.     var $authority;
  32.  
  33.     /** 認証文字列(認証成功の判定に使用) */
  34.     var $cert;
  35.  
  36.     /** セッションID */
  37.     var $sid;
  38.  
  39.     /** ログインユーザの主キー */
  40.     var $member_id;
  41.  
  42.     /** ページ遷移の正当性チェックに使用 */
  43.     var $uniqid;
  44.  
  45.     /* コンストラクタ */
  46.     function SC_Session({
  47.         // セッション情報の保存
  48.         if(isset($_SESSION['cert'])) {
  49.             $this->sid = session_id();
  50.             $this->cert = $_SESSION['cert'];
  51.             $this->login_id  = $_SESSION['login_id'];
  52.             // 管理者:0, 店舗オーナー:1, 閲覧:2, 販売担当:3 (XXX 現状 0, 1 を暫定実装。2, 3 は未実装。)
  53.             $this->authority = $_SESSION['authority'];
  54.             $this->member_id = $_SESSION['member_id'];
  55.             if (isset($_SESSION['uniq_id'])) {
  56.                 $this->uniqid    = $_SESSION['uniq_id'];
  57.             }
  58.  
  59.             // ログに記録する
  60.             GC_Utils_Ex::gfPrintLog("access : user=".$this->login_id." auth=".$this->authority." sid=".$this->sid);
  61.         else {
  62.             // ログに記録する
  63.             GC_Utils_Ex::gfPrintLog("access error.");
  64.         }
  65.     }
  66.     /* 認証成功の判定 */
  67.     function IsSuccess({
  68.         if ($this->cert == CERT_STRING{
  69.             $masterData new SC_DB_MasterData_Ex();
  70.             $admin_path preg_replace('/\/+/''/'$_SERVER['PHP_SELF']);
  71.             $arrPERMISSION $masterData->getMasterData("mtb_permission");
  72.             if (isset($arrPERMISSION[$admin_path])) {
  73.                 // 数値が自分の権限以上のものでないとアクセスできない。
  74.                 if ($arrPERMISSION[$admin_path$this->authority{
  75.                     return AUTH_ERROR;
  76.                 }
  77.             }
  78.             return SUCCESS;
  79.         }
  80.  
  81.         return ACCESS_ERROR;
  82.     }
  83.  
  84.     /* セッションの書き込み */
  85.     function SetSession($key$val{
  86.         $_SESSION[$key$val;
  87.     }
  88.  
  89.     /* セッションの読み込み */
  90.     function GetSession($key{
  91.         return $_SESSION[$key];
  92.     }
  93.  
  94.     /* セッションIDの取得 */
  95.     function GetSID({
  96.         return $this->sid;
  97.     }
  98.  
  99.     /** ユニークIDの取得 **/
  100.     function getUniqId({
  101.         // ユニークIDがセットされていない場合はセットする。
  102.         ifempty($_SESSION['uniqid']) ) {
  103.             $this->setUniqId();
  104.         }
  105.         return $this->GetSession('uniqid');
  106.     }
  107.  
  108.     /** ユニークIDのセット **/
  109.     function setUniqId({
  110.         // 予測されないようにランダム文字列を付与する。
  111.         $this->SetSession('uniqid'SC_Utils_Ex::sfGetUniqRandomId());
  112.     }
  113.  
  114.     /* セッションの破棄 */
  115.     function EndSession({
  116.         // デフォルトは、「PHPSESSID」
  117.         $sname session_name();
  118.         // セッション変数を全て解除する
  119.         $_SESSION array();
  120.         // セッションを切断するにはセッションクッキーも削除する。
  121.         // Note: セッション情報だけでなくセッションを破壊する。
  122.         if (isset($_COOKIE[$sname])) {
  123.             setcookie($sname''time()-42000'/');
  124.         }
  125.         // 最終的に、セッションを破壊する
  126.         session_destroy();
  127.         // ログに記録する
  128.         GC_Utils_Ex::gfPrintLog("logout : user=".$this->login_id." auth=".$this->authority." sid=".$this->sid);
  129.     }
  130.  
  131.     // 関連セッションのみ破棄する。
  132.     function logout({
  133.         unset($_SESSION['cert']);
  134.         unset($_SESSION['login_id']);
  135.         unset($_SESSION['authority']);
  136.         unset($_SESSION['member_id']);
  137.         unset($_SESSION['uniqid']);
  138.         // トランザクショントークンを破棄
  139.         SC_Helper_Session_Ex::destroyToken();
  140.         // ログに記録する
  141.         GC_Utils_Ex::gfPrintLog("logout : user=".$this->login_id." auth=".$this->authority." sid=".$this->sid);
  142.     }
  143. }
  144. ?>

Documentation generated on Fri, 24 Feb 2012 14:02:56 +0900 by Seasoft